package net.gyapp.markim.testing;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.easyder.wrapper.base.view.WrapperSwipeActivity;
import com.easyder.wrapper.core.model.BaseVo;
import com.easyder.wrapper.utils.LogUtils;
import com.xuhao.android.libsocket.sdk.ConnectionInfo;
import com.xuhao.android.libsocket.sdk.ISendableIml;
import com.xuhao.android.libsocket.sdk.OkSocket;
import com.xuhao.android.libsocket.sdk.OkSocketOptions;
import com.xuhao.android.libsocket.sdk.SocketActionAdapter;
import com.xuhao.android.libsocket.sdk.bean.ISendable;
import com.xuhao.android.libsocket.sdk.connection.IConnectionManager;

import net.gyapp.markim.ApiConfig;
import net.gyapp.markim.R;
import net.gyapp.markim.core.ImManager;
import net.gyapp.markim.module.basic.base.CommonPresenter;
import net.gyapp.markim.utils.RequestParams;

import org.jim.common.base.ImPacket;
import org.jim.common.packets.ChatBody;
import org.jim.common.packets.Command;
import org.jim.common.packets.LoginReqBody;
import org.jim.common.tcp.TcpPacket;

import java.io.UnsupportedEncodingException;

import butterknife.OnClick;
import me.winds.widget.usage.TitleView;

/**
 * Author:  winds
 * Data:    2018/7/16
 * Version: 1.0
 * Desc:
 */


public class ImTestActivity extends WrapperSwipeActivity<CommonPresenter> {

    public static Intent getIntent(Context context) {
        return new Intent(context, ImTestActivity.class);
    }

    @Override
    protected int getViewLayout() {
        return R.layout.activity_im_test;
    }

    @Override
    protected void initView(Bundle savedInstanceState, TitleView titleView, Intent intent) {
        titleView.setCenterText("测试");
    }

    @Override
    public void showContentView(String url, BaseVo dataVo) {

    }

    @Override
    protected void loadData(Bundle savedInstanceState, Intent intent) {

    }

    @OnClick({R.id.btn_connect, R.id.btn_login, R.id.btn_heart, R.id.btn_send_test})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_connect:
//                initSocket();
                ImManager.getInstance().getOfflineMessage();
                break;
            case R.id.btn_login:
//                login();
                break;
            case R.id.btn_heart:
                break;
            case R.id.btn_send_test:
//                test();
                break;
        }
    }



    /**
     * 获取群成员信息
     *
     * @param groupNumber
     */
    private void getGroupUser(String groupNumber) {
        presenter.setNeedDialog(false);
        presenter.postData(ApiConfig.API_GET_GROUP_USERS, new RequestParams().put("groupNumber", groupNumber).get());
    }

    /**
     * 获取群信息
     *
     * @param groupNumber
     */
    private void getGroupInfo(String groupNumber) {
        presenter.setNeedDialog(false);
        presenter.postData(ApiConfig.API_GET_GROUP_INFO, new RequestParams().put("groupNumber", groupNumber).get());
    }

    /**
     * 获取群申请信息
     */
    private void getGroupVerifyInfo() {
        presenter.setNeedDialog(false);
        presenter.postData(ApiConfig.API_GET_GROUP_VERIFY_INFO, BaseVo.class);
    }

    /**
     * 获取群屏蔽状态
     *
     * @param groupId
     */
    private void getGroupShieldStatus(String groupId) {
        presenter.setNeedDialog(false);
        presenter.postData(ApiConfig.API_GET_SHIELD_GROUP_STATUS, new RequestParams().put("groupId", groupId).get(), BaseVo.class);
    }

    /**
     * 设置群屏蔽
     *
     * @param groupId
     */
    private void setGroupShieldStatus(String groupId) {
        presenter.setNeedDialog(false);
        presenter.postData(ApiConfig.API_GET_SHIELD_GROUP_STATUS, new RequestParams().put("groupId", groupId).get(), BaseVo.class);
    }


    /**
     * 获取群小程序
     *
     * @param groupNumber
     */
    private void getGroupProject(String groupNumber) {
        presenter.setNeedDialog(false);
        presenter.postData(ApiConfig.API_GET_SMALL_PROGRAM, new RequestParams().put("groupNumber", groupNumber).get());
    }

    /**
     * 设置群小程序
     *
     * @param groupNumber
     * @param groupTitle
     * @param groupTitleUrl
     */
    private void setGroupProject(String groupNumber, String groupTitle, String groupTitleUrl) {
        presenter.setNeedDialog(false);
        presenter.postData(ApiConfig.API_GET_SMALL_PROGRAM, new RequestParams().put("groupNumber", groupNumber).put("groupTitle", groupTitle).put("groupTitleUrl", groupTitleUrl).get());
    }

    /**
     * 更新群通知
     *
     * @param groupNumber
     * @param groupNotice
     */
    private void updateGroupNotice(String groupNumber, String groupNotice) {
        presenter.setNeedDialog(false);
        presenter.postData(ApiConfig.API_GET_SMALL_PROGRAM, new RequestParams().put("groupNumber", groupNumber).put("groupNotice", groupNotice).get());
    }

    /**
     * 同意入群
     *
     * @param groupUsersId
     */
    private void setAgreeEntryGroup(String groupUsersId) {
        presenter.setNeedDialog(false);
        presenter.postData(ApiConfig.API_AGREE_USER_ENTRY_GROUP, new RequestParams().put("groupUsersId", groupUsersId).get());
    }

    /**
     * 拒绝入群
     *
     * @param groupUsersId
     */
    private void setRefuseEntryGroup(String groupUsersId) {
        presenter.setNeedDialog(false);
        presenter.postData(ApiConfig.API_AGREE_USER_ENTRY_GROUP, new RequestParams().put("groupUsersId", groupUsersId).get());
    }



}
